package com.myy.auth.controller;

import com.myy.auth.service.MenuService;
import com.myy.auth.vo.MenuVo;
import com.myy.common.result.Result;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 菜单接口
 */
@RestController
@RequestMapping("menu")
public class MenuController {

    private final MenuService menuService;

    public MenuController(MenuService menuService) {
        this.menuService = menuService;
    }

    /**
     * 创建菜单
     */
    @PostMapping("save")
    public Result<String> saveOrUpdate(@RequestBody List<MenuVo> list){
        return Result.success(menuService.saveOrUpdate(list));
    }
    /**
     * 菜单结构
     * @param systemid 全部系统or单个系统
     */
    @GetMapping("tree")
    public Result<List<MenuVo>> tree(@RequestParam(required = false) String systemid){
        return Result.success(menuService.tree(systemid));
    }
}
